﻿using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace CN2P.ServiceModel
{
    [DataContract]
    public class ProductModelPagedList
    {
        public ProductModelPagedList(IList<ProductModel> allItems, int pageIndex, int pageSize)
        {
            if (null != allItems)
            {
                this.Products = allItems
                    .Skip((pageIndex - 1)*pageSize)
                    .Take(pageSize)
                    .ToList();
                this.TotalCount = allItems.Count;
            }
        }

        [DataMember(Name = "totalCount")]
        public int TotalCount { get; set; }

        [DataMember(Name = "products")]
        public IList<ProductModel> Products { get; set; }
    }
}